import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MarketVO, MarketForm, MarketQuery } from '@/api/market/market/types';

/**
 * 查询Market信息列表
 * @param query
 * @returns {*}
 */

export const listMarket = (query?: MarketQuery): AxiosPromise<MarketVO[]> => {
  console.log('【调试】请求参数：', query); // 添加此行
  return request({
    url: '/api/stock/marketList',
    method: 'get',
    params: query
  });
};

/**
 * 查询Market信息详细
 * @param id
 */
export const getMarket = (id: string | number): AxiosPromise<MarketVO> => {
  return request({
    url: '/api/stock/' + id,
    method: 'get'
  });
};

/**
 * api新增Market信息
 * @param data
 */
export const addMarket = (data: MarketForm) => {
  return request({
    url: '/api/stock/getStock',
    method: 'get',
    data: data
  });
};

/**
 * 修改Market信息
 * @param data
 */
export const updateMarket = (data: MarketForm) => {
  return request({
    url: '/api/stock',
    method: 'put',
    data: data
  });
};

/**
 * 删除Market信息
 * @param id
 */
export const delMarket = (id: string | number | Array<string | number>) => {
  return request({
    url: '/api/stock/' + id,
    method: 'delete'
  });
};

// 查询所有股票代码
export const listSymbols = (): AxiosPromise<string[]> => {
  return request({
    url: '/api/stock/symbols',
    method: 'get'
  });
};
